#include <cstdio>
#include <cstring>
#include <cmath> 
#include <queue>
using namespace std;
const int N = 3e3 + 5, M = N * N, INF = 0x3f3f3f3f;
struct E {
	int v, next;
} e[M];
struct Node {
	double x, y, s;
} a[N], b[N];
int n, m, k, t, len, dis, h[N], mx[N], my[N], dx[N], dy[N];
bool vis[N]; 
void add(int u, int v) {
	e[++len].v = v;
	e[len].next = h[u];
	h[u] = len;
}
bool bfs() {
	queue<int> q;
	memset(dx, -1, sizeof(dx));
	memset(dy, -1, sizeof(dy));
	//找出未匹配的点 (左边)
	for (int i = 1; i <= n; i++) {
		if (mx[i] == -1) q.push(i), dx[i] = 0;
	}	
	dis = INF; //初始令增广路为无穷 
	while (!q.empty()) {
		int u = q.front(); q.pop();
		if (dx[u] > dis) break; //代表还有比dis更长的增广路 留待下次bfs扩展
		for (int j = h[u]; j; j = e[j].next) {
			int v = e[j].v; 
			if (dy[v] == -1) { //代表还未遍历过 
				dy[v] = dx[u] + 1; //给予层次
				if (my[v] == -1) {
					dis = dy[v]; //找到增广路 
				} else {
					//如果已经匹配了 就把匹配好的点（左边）放入队列进行扩展 
					dx[my[v]] = dy[v] + 1;
					q.push(my[v]);
				}
			}
		} 
	}
	return dis != INF; //等于INF就未找到增广路 
}
bool dfs(int u) {
	for (int j = h[u]; j; j = e[j].next) {
		int v = e[j].v;
		if (vis[v] || dy[v] != dx[u] + 1) continue; //如果未访问且是u的下层次点 
		vis[v] = true; 
		if (my[v] != -1 && dy[v] == dis) continue; //如果这个点已经匹配 且找到的增广路已经大于dis 
		if (my[v] == -1 || dfs(my[v])) {
			my[v] = u; mx[u] = v;
			return true;
		}
	}
	return false;
} 
int getMax() {
	int ans = 0;
	memset(mx, -1, sizeof(mx));
	memset(my, -1, sizeof(my));
	while (bfs()) { //查找是否有增广路 
		memset(vis, false, sizeof(vis)); //对于找到的一条增广路径查询 
		for (int i = 1; i <= n; i++) {
			if (mx[i] == -1 && dfs(i)) ans++; //如果未匹配才去dfs 
		} 		
	}
	return ans;
}
int main() {
	scanf("%d", &t);
	for (int T = 1; T <= t; T++) {
		memset(h, 0, sizeof(h)); len = 0;
		scanf("%d%d", &k, &n);
		for (int i = 1; i <= n; i++) {
			scanf("%lf%lf%lf", &a[i].x, &a[i].y, &a[i].s);
		}
		scanf("%d", &m);
		double x, y;
		for (int i = 1; i <= m; i++) {
			scanf("%lf%lf", &b[i].x, &b[i].y); //建立二分图 
		} 
		for (int i = 1; i <= m; i++) {
			x = b[i].x, y = b[i].y;	
			for (int j = 1; j <= n; j++) {
				double fx = a[j].x - x;
				double fy = a[j].y - y;
				double d = sqrt(fx*fx + fy*fy);
				if (d <= k * a[j].s) add(j, i);
			}
		}
		int ans = getMax();
		printf("Scenario #%d:\n%d\n\n", T, ans); 
	}	
	return 0;
}